<template>
  <div class="home">
    <router-view v-slot="{ Component, route }">
      <transition name="router-fade" mode="out-in">
        <component :is="Component" :key="route.matched?.[1]?.path" />
      </transition>
    </router-view>
  </div>
</template>

<script setup>
import useUserStore from "@/store/modules/user";
import { setLocalCache } from "@/utils/cache";
import defaultConfig from "@/settings";
import useReceiveMainData from "@/hooks/microApp/useReceiveMainData";
import { isMicroApp } from "@/microApp";
import { onMounted } from "vue";

const getMainAppData = () => {
  if (isMicroApp()) {
    const userStore = useUserStore();
    const { userInfo, token, roles } = useReceiveMainData();
    userStore.userInfo = userInfo?.value || {};
    userStore.roles = roles?.value || [];
    setLocalCache(defaultConfig.tokenAttr, token?.value || "");
  }
};

onMounted(() => {
  // getMainAppData();
});
</script>
<style scoped lang="scss">
.home {
  height: 100%;
}
</style>
